﻿@{
    ViewBag.Title = "我关注的项目";
    Layout = "~/Views/Shared/_LayoutFore.cshtml";
}
<link href="~/Scripts/laypage/skin/laypage.css" rel="stylesheet" />

<div class="RightContrent">
    <div style="margin-left: 50px; margin-right: 50px;">
        <div class="tab-content">
            <div class="line10"></div>
            <div class="line10"></div>
            <div class="tab_title">@ViewBag.Title</div>
            <div class="tab-content">
                <div style="width: 16px; height: 12px; float: left;">
                    <img src="~/Content/Images/leftarraw.png" />
                </div>
            </div>

            <div class="tab-content_border">
                <div class="u-center">
                    <form id="formQuery" class="form-inline" role="form">
                    </form>
                    <input type="hidden" name="Id" id="Id" value="@ViewBag.MemberId" >
                    <div class="line10"></div>
                    <div id="gridlist" class="xjgrid">
                        <div class="grid-body">
                            <div class="grid-body-inner">
                                <table id="gridlist_detail">
                                    <thead>
                                        <tr class="thead">
                                            <td style="width: 15%" class="sortable">
                                                <div style="text-align: left;">项目信息</div>
                                            </td>
                                            <td style="width: 45%" class="sortable"></td>
                                            <td style="width: 15%" class="sortable">
                                                <div style="text-align: left;">支持人数</div>
                                            </td>
                                            <td style="width: 15%">
                                                <div style="text-align: center;">关注人数</div>
                                            </td>
                                            <td style="width: 10%">
                                                <div style="text-align: center;">操作</div>
                                            </td>
                                        </tr>
                                    </thead>
                                    <tbody class="DataList">
                                        <tr id="gridlist_tr_0" class="">
                                            <td><a class="b-l-img ThumImage" target="_blank"></a>
                                            </td>
                                            <td class="td-left">
                                                <div class="clearfix">
                                                    <a class="b-l-name" href="" data-bind="ProjectName" target="_blank"></a>
                                                    <p class="b-l-tag-green" data-bind="AuditStatus"></p>

                                                    <br />
                                                    <br />

                                                </div>
                                                <div class="b-l-info clearfix">
                                                    <div class="b-l-i-list">
                                                        <p>已完成</p>
                                                        <p class="size14" data-bind="StrProjectPercent">
                                                            117%
                                                        </p>
                                                    </div>
                                                    <div class="b-l-i-list">
                                                        <p>已筹集</p>
                                                        <p class="size14" data-bind="CurrentAmount">¥0</p>
                                                    </div>
                                                    <div class="b-l-i-list">
                                                        <p>剩余时间</p>
                                                        <p class="size14" data-bind="StrRemainDays">0 天</p>
                                                    </div>
                                                </div>
                                            </td>
                                            <td>
                                                <p class="b-l-price-red " data-bind="Zc">1</p>
                                            </td>
                                            <td>
                                                <p class="b-l-price-red " data-bind="Guanzhu">0</p>
                                            </td>
                                            <td>
                                                <p>
                                                    <a class="b-l-btn Support">去支持</a>
                                                </p>
                                                <p>
                                                    <a class="b-l-btn listDelete">取消关注</a>
                                                </p>
                                                <input type="hidden" value="" id="check">
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                            <div class="xjgrid-load" style="display: none;">
                                <img src="../../assets/layer/skin/default/xubox_loading2.gif">加载中...
                            </div>
                        </div>
                        <div id="gridlist_pagep" class="grid-pagination">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@section script{
    <script src="~/Scripts/laypage/laypage.js"></script>
    <script src="~/Scripts/transparency.min.js"></script>
    <script type="text/javascript">
        var options = {
            listUrl: "@Url.Action("FocusProject")"
        };
        $(function () {
            LoadData(1);
        });
        var pages = 0;

        function LoadData(curr) {
            var url = options.url;
            $.ajax({
                url: url,
                type: 'Post',
                dataType: 'json',
                data: {
                    sortname: "pAtt.Id",
                    sortorder: "DESC",
                    title: false,
                    rp: 5,
                    usepager: true,
                    page: curr,
                    showcheckbox: false
                },
                success: function (result) {
                    if (result.DataList == null)
                        return;
                    var post = result.DataList;
                    var directives = {
                        ThumImage: {
                            html: function () {
                                return "<img style='width: 100px; height: 100px' src='" + this.ProjectThumImage + "  '>";
                            },
                            href: function () {
                                return "@Url.Action("Detail", "Default")?Id=" + this.Id;
                            }
                        },
                        ProjectName: {
                            href: function () {
                                return "@Url.Action("Detail", "Default")?Id=" + this.Id;
                            }
                        },
                        AuditStatus: {
                            html: function () {
                                var html = "";
                                if (this.AuditStatus == 0) {
                                    html = "已保存";

                                } else if (this.AuditStatus > 109 && this.AuditStatus < 210) {
                                    html = "审核中";

                                } else if (this.AuditStatus == 210 && this.ProjectStatus != 8) {
                                    html = "众筹中";

                                } else if (this.AuditStatus == 109) {
                                    html = "不通过";

                                } else if (this.AuditStatus == 220) {
                                    html = "众筹成功";

                                } else if (this.AuditStatus == 219) {
                                    html = "众筹失败";
                                } else if (this.ProjectStatus == 8) {
                                    html = "预热中";
                                }
                                return html;
                            }
                        },
                        listDelete: {
                            href: function () {
                                return "javascript: doDelete(" + this.Id + ")"; // @@Url.Action("CancelAttention", "UserProject")?Id=" + ; 
                            }
                        },
                        Support: {
                            href: function () {
                                return "javascript:GoToSupport(" + this.Id + ")";
                            }
                        }
                    };
                    $('.DataList').render(post, directives);
                    if (result.TotalPage > 0) {
                        pages = result.TotalPage;
                    }
                    laypage({
                        cont: 'gridlist_pagep', //容器。值支持id名、原生dom对象，jquery对象。【如该容器为】：<div id="page1"></div>
                        pages: pages, //通过后台拿到的总页数
                        curr: result.PageIndex + 1, //当前页
                        jump: function (obj, first) { //触发分页后的回调
                            if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr  
                                LoadData(obj.curr);
                            }
                        }
                    });
                }
            });
        }

        function selectMyProject(obj, status) {
        }

        function doDelete(id) {
            $.dialog.confirm('你确定要取消吗？', function () {
                $.post("/UserProject/CancelAttention" + "/" + id, { id: id },
                    function (res) {
                        if (res.Status > 0) {
                            location.href = location.href;
                        } else {
                            $.dialog.tips(res.Message);
                        }
                    },
                    "json"
                );
            });

        }

        function GoToSupport(id) {
            window.location.href = "/Default/Detail" + "/" + id;
        }
    </script>
}